package com.wangyadong.hobby.schedule.jobtask.dsa.recursive;

public class BinarySearch {

    private static int low = 0;
    private static int[] data = {2, 5, 7, 8, 10, 23, 45, 78, 79};
    private static int hight = data.length;

    public static void main(String[] args) {
        boolean binarySearch = binarySearch(low, data.length - 1, 23);
        System.out.println(binarySearch);
    }


    public static boolean binarySearch(int low, int high, int tagert) {
        if (low > high) {
            return false;
        } else {
            int mid = (low + high) / 2;
            if (data[mid] == tagert) {
                return true;
            } else if (data[mid] < tagert) {
                return binarySearch(mid + 1, high, tagert);
            } else {
                return binarySearch(low, mid -1, tagert);
            }
        }

    }
}
